

var Ajax = {

  _RET_NULL   : " ",
  _CONN_ERROR : "****",

  setGlSubAccCode : function (thisObj,
                              glAccCode,
                              glSubAccName){
    
    glAccCode     = document.getElementsByName(glAccCode);
    glSubAccName  = document.getElementsByName(glSubAccName);
    
    glAccCode     = GMisc.firstElement(glAccCode);
    glSubAccName  = GMisc.firstElement(glSubAccName);
    
    var url = "/ecs/tocmenu_31/controllers/getGlSubAcc.php";
    
    var params = "glSubAccName="  + glSubAccName.value +
                 "&glAccCode="    + glAccCode.value ;
    
    var responseText = GAjax.SJax(url,
                                  params);
    //alert(responseText);
    switch(responseText){
            
      case this._CONN_ERROR:
        
        alert("Db connection failed");
        break;
        
      case this._RET_NULL:
        
        alert("Error has been occured");
        break;
        
      default:
        
        thisObj.value = responseText;
    }
  },

  setGlSubAcc : function (thisObj,
                          glAccCode){
  
    glAccCode = document.getElementsByName(glAccCode);
    
    glAccCode = GMisc.firstElement(glAccCode);
    
    var url = "/ecs/tocmenu_31/controllers/getGlSubAcc.php";
    
    var params = "glSubAcc="    + thisObj.value   +
                 "&glAccCode="  + glAccCode.value +
                 "&isList=1" ;
    
    var responseText = GAjax.SJax(url,
                                  params);
    //alert(responseText);
    switch(responseText){
            
      case this._CONN_ERROR:
        
        alert("Db connection failed");
        break;
        
      case this._RET_NULL:
        
        alert("Error has been occured");
        break;
        
      default:
        
        thisObj.innerHTML = responseText;
    }
  },

  setGlAccCode : function (thisObj,
                           glAccName){
  
    glAccName = document.getElementsByName(glAccName);
    
    glAccName = GMisc.firstElement(glAccName);
    
    var url = "/ecs/tocmenu_31/controllers/getGlAcc.php";
    
    var params = "glAccName="     + glAccName.value;
    
    var responseText = GAjax.SJax(url,
                                  params);
    //alert(responseText);
    switch(responseText){
            
      case this._CONN_ERROR:
        
        alert("Db connection failed");
        break;
        
      case this._RET_NULL:
        
        alert("Error has been occured");
        break;
        
      default:
        
        thisObj.value = responseText;
    }
  },

  setGlAcc : function (thisObj){
  
    var url = "/ecs/tocmenu_31/controllers/getGlAcc.php";
    
    var params = "glAcc="     + thisObj.value +
                 "&isList=1";
    
    var responseText = GAjax.SJax(url,
                                  params);
    //alert(responseText);
    switch(responseText){
            
      case this._CONN_ERROR:
        
        alert("Db connection failed");
        break;
        
      case this._RET_NULL:
        
        alert("Error has been occured");
        break;
        
      default:
        
        thisObj.innerHTML = responseText;
    }
  },

  getRate : function (srcSymbol,
                      trDate,
                      rate){
	  
	  trDate = document.getElementsByName(trDate);
	  rate   = document.getElementsByName(rate);
	  
	  trDate = GMisc.firstElement(trDate);
	  rate   = GMisc.firstElement(rate);
	  
	  if(srcSymbol.length > 0){
	    
	    var xmlHttp = new XMLHttpRequest();
	    
	    var url     = "/ecs/tocmenu_43/controllers/getRate.php" +"?sid="+Math.random();
	    var params  = "srcSymbol="    + srcSymbol +
	                  "&trDate="      + trDate.value ;
	    
	    xmlHttp.open("POST", url, false);
	    
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlHttp.setRequestHeader("Content-length", params.length);
	    xmlHttp.setRequestHeader("Connection", "close");
	    
	    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
	      
	    }
	    
	    xmlHttp.send(params);
	    
	    switch(xmlHttp.responseText){
            
        case this._CONN_ERROR:
          
          alert("Db connection failed");
          break;
          
        case this._RET_NULL:
          
          alert("Error has been occured");
          break;
          
        default:
          
          rate.value = xmlHttp.responseText;
      }
	  }
	},

  setCbName : function (thisObj,
                        cbCode){
  
    cbCode   = document.getElementsByName(cbCode);
    
    cbCode   = GMisc.firstElement(cbCode);
  
    var xmlHttp = new XMLHttpRequest();
    
    var url     = "/ecs/tocmenu_31/controllers/getCb.php" +"?sid="+Math.random();
    var params  = "cbCode=" + cbCode.value;
    
    xmlHttp.open("POST", url, false);
    
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
      
    }
    
    xmlHttp.send(params);
    //alert(xmlHttp.responseText);
    thisObj.value = xmlHttp.responseText;
  },

  setCbCode : function (thisObj){
  
    var xmlHttp = new XMLHttpRequest();
    
    var url     = "/ecs/tocmenu_31/controllers/getCb.php" +"?sid="+Math.random();
    var params  = "cbCode=" + thisObj.value +
                  "&isList=1";
    
    xmlHttp.open("POST", url, false);
    
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
      
    }
    
    xmlHttp.send(params);
    //alert(xmlHttp.responseText);
    thisObj.innerHTML = xmlHttp.responseText;
  },

  suppCstCode : function (suppCstCode,
                          suppCstEnt,
                          typeEnt){
    
    suppCstCode   = document.getElementsByName(suppCstCode);
    suppCstEnt    = document.getElementsByName(suppCstEnt);
    typeEnt       = document.getElementsByName(typeEnt);
    
    suppCstCode   = GMisc.firstElement(suppCstCode);
    suppCstEnt    = GMisc.firstElement(suppCstEnt);
    typeEnt       = GMisc.firstElement(typeEnt);
    
    var xmlHttp = new XMLHttpRequest();
    
    var url     = "/ecs/tocmenu_31/controllers/getSuppCustCode.php" +"?sid="+Math.random();
    var params  = "type="         + typeEnt.value +
                  "&suppCstName=" + suppCstEnt.value;
    
    xmlHttp.open("POST", url, false);
    
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
      
    }
    
    xmlHttp.send(params);
    //alert(xmlHttp.responseText);
    suppCstCode.value = xmlHttp.responseText;
  },

  suppCst : function (suppCstEnt,
                      typeEnt){
    
    suppCstEnt  = document.getElementsByName(suppCstEnt);
    typeEnt     = document.getElementsByName(typeEnt);
    
    suppCstEnt  = GMisc.firstElement(suppCstEnt);
    typeEnt     = GMisc.firstElement(typeEnt);
    
    var xmlHttp = new XMLHttpRequest();
    
    var url     = "/ecs/tocmenu_31/controllers/getSuppCust.php" +"?sid="+Math.random();
    var params  = "type="    + typeEnt.value;
    
    xmlHttp.open("POST", url, false);
    
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
      
    }
    
    xmlHttp.send(params);
    //alert(xmlHttp.responseText);
    suppCstEnt.innerHTML = xmlHttp.responseText;
  },

  setButton : function (tx,
                        customButton){
  
    tx            = document.getElementsByName(tx);
    customButton  = document.getElementsByName(customButton);
    
    tx            = GMisc.firstElement(tx);
    customButton  = GMisc.firstElement(customButton);
    
    var xmlHttp = new XMLHttpRequest();
    
    var url     = "/ecs/tocmenu_31/controllers/getButton.php" +"?sid="+Math.random();
    var params  = "theTx="    + tx.value;
    
    xmlHttp.open("POST", url, false);
    
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
      
    }
    
    xmlHttp.send(params);
    //alert(xmlHttp.responseText);
    customButton.innerHTML = xmlHttp.responseText;
  },

  sayHello : function(){

    alert("Ajax Linked");
  }
} 